import store from '@/store'
//检查字符串是否为空
export function jian_cha_shi_fou_wei_kong(data) {

    if (data == null) {
        return false;
    }
    else {
        const judge_my_input = data.trim();
        if (judge_my_input == 0) {
            return false;
        }
    }
    return true;
}


// 判断富文本编辑器输入是否为空或回车
export function getText(str) {
    return str
        .replace(/<[^<p>]+>/g, '')  // 将所有<p>标签 replace ''
        .replace(/<[</p>$]+>/g, '')  // 将所有</p>标签 replace ''
        .replace(/&nbsp;/gi, '')  // 将所有 空格 replace ''
        .replace(/<[^<br/>]+>/g, '') // 将所有 换行符 replace ''
}




//是否登录并跳转
export function is_login() {
    if (store.state.user_main.user.b_user_id == null) {

        window.open(`${process.env.VUE_APP_TIAO_ZHUAN}/user_login`);
        throw new Error("null");
    }
}

//是否登录不跳转 
export function is_login_not_tiao_zhuan() {
    if (store.state.user_main.user.b_user_id == null) {
        throw new Error("null");
    }
}


//收藏_点赞_浏览的实现
export function dian_zan_shou_cang_liu_lan(status, class_id, connect, other) {
    const like_his_coll = {
        b_favorite_status: status,
        b_class_id: class_id,
        b_key_connect: connect,
        b_other_nei: other,
    }
    store.commit("user_main/charge_the_like_history_collect", like_his_coll);
}


